package com.ruoyi.mateTemplate.controller;

import com.alibaba.fastjson.JSONArray;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.mateTemplate.domain.ProductTemplate;
import com.ruoyi.mateTemplate.domain.ProductTemplateModel;
import com.ruoyi.mateTemplate.service.TemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author
 * @Version 1.0
 */
@RestController
@RequestMapping("/template")
public class TemplateController extends BaseController {

    @Autowired
    TemplateService templateService;

    @PostMapping("/insertTemplate")
    @ResponseBody
    public AjaxResult insertTemplate(@RequestBody ProductTemplate productTemplate) {
        int a = templateService.insertTemplate(productTemplate);
        return AjaxResult.success("添加成功");

    }

    @GetMapping("/selectTemplate")
    @ResponseBody
    public Map<String,Object> selectTemplate(@RequestParam(value = "productId", required = false) Long productId) {
        ProductTemplate list = templateService.selectTemplate(productId);
        Map<String,Object> resMap=new HashMap<>();
        resMap.put("result",list);
        return resMap;
    }


}
